<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.UUID"%>
<%@ page import="java.sql.Timestamp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>设备监测管理系统</title>
	<link rel="stylesheet" type="text/css" href="<%=this.getServletContext().getContextPath()%>/jsfiles/jquery-easyui-1.3.6/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=this.getServletContext().getContextPath()%>/jsfiles/jquery-easyui-1.3.6/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="<%=this.getServletContext().getContextPath()%>/jsfiles/jquery-easyui-1.3.6/demo/demo.css">
    
    <script type="text/javascript" src="<%=this.getServletContext().getContextPath()%>/jsfiles/jquery-easyui-1.3.6/jquery.min.js"></script>
	<script type="text/javascript" src="<%=this.getServletContext().getContextPath()%>/jsfiles/jquery-easyui-1.3.6/jquery.easyui.min.js"></script>
<!-- script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script-->
	
	<script type="text/javascript">
	
		function GetRandomNum(Min,Max)
		{   
			var Range = Max - Min;   
			var Rand = Math.random();   
			return(Min + Math.round(Rand * Range));   
		}   
				
		//每秒写入测试数据	
		function writeTestData(){
			var temp = GetRandomNum(1,50);
			var humi = GetRandomNum(1,50);
			var curr = new Date();
			var time = curr.getTime();
			//alert(curr.toString());	
			var param = "state.guid=601a68e1-66f8-484c-9497-4cecb920c83c&state.humidity=" + humi +
			"&state.occurTime=" + time + "&state.temperature=" + temp;		
        	//alert(param);
        	$.ajax({       
	            url:'<%=this.getServletContext().getContextPath()%>/DeviceState/StateTest!WriteTestData',  
	            type:'post',  
	            data: param,  
	            dataType:'json',          
	            success:function (data) {
	                //alert("SUCCESS");         
	            },
	            complete:function( XMLHttpRequest, textStatus ){
	            	//alert("complete");   
	            },
	            error:function( XMLHttpRequest, textStatus, errorThrown){
	            	//alert( "error:"+ errorThrown );
	            }    
        	});
				
	}
	
	writeTestData();
	setInterval(writeTestData,5000);
	
	
	</script>

</head>
<body> 
    <div><h2 style="width:800px;text-align:center">数据测试页</h2></div>
    <div>周期(1s)向数据库写入数据模拟环境</div>
    
   
</body>

</html>